(function(window) {
	//public variable, access via object.name properties
	Common.prototype.size = 100;

	//static variable, access via name class.name constant
	Common.constant = 1000;
	function Common() {
		//Varibale private
	}
	Common.prototype.hello = function() {
		console.log("teo");
	}

	/**
	 * Function create cookie on browser 
	 * @name: Type string is name of cookie
	 * @value: Set value for cookie 
	 * @day: Time out of cookie
	 * */
	Common.prototype.createCookie = function(name, value, days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
			var expires = "; expires=" + date.toGMTString();
		} else
			var expires = "";
		document.cookie = name + "=" + value + expires + "; path=/";
	}

	/**
	 * Function get vaule of cookie
	 * @name: Name of cookie want get value
	 * @return: Value cookie or null
	 * */
	Common.prototype.getCookie = function(name) {
		if (document.cookie.length > 0) {
			c_start = document.cookie.indexOf(name + "=");
			if (c_start != -1) {
				c_start = c_start + name.length + 1;
				c_end = document.cookie.indexOf(";", c_start);
				if (c_end == -1) {
					c_end = document.cookie.length;
				}
				return unescape(document.cookie.substring(c_start, c_end));
			}
		} else {
			return "null";
		}
	}

	/**
	 * Function delete cookie 
	 * @name: Name of cookie want delete
	 * */
	Common.prototype.deleteCookie = function(name) {
		document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
	}

	/**
	 *Function check content containner special html
	 *@Content: Content  
	 **/
	Common.prototype.checkInjectedCodde = function(content) {
		var regex = /<\s*\/\s*\w\s*.*?>|<\s*br\s*>/g;
		if (regex.test(content) == true) {
			return false;
		} else {
			return true;
		}
	}

	/**
	 * Function compare size of file
	 * @size: Size of file
	 * @maxSize: Size allow input
	 * */
	Common.prototype.checkSizeOfFile = function(size, maxSize) {
		if (size < maxSize) {
			return 1;
		} else {
			return 0;
		}
	}

	/**
	 * Function check variable exits
	 * @variable: variable name 
	 * */
	Common.prototype.checkExitsVariable = function(variable) {
		if (typeof variable != 'undefined') {
			return 1;
		} else {
			return 0;
		}
	}

	/**
	 * Count word in string
	 * @str: String want count
	 * **/
	Common.prototype.countWordInString = function(str, max) {
		str = str.replace(/(^\s*)|(\s*$)/gi, "");//exclude  start and end white-space
		str = str.replace(/[ ]{2,}/gi, " ");//2 or more space to 1
		str = str.replace(/\n /, "\n"); // exclude newline with a start spacing
		if (str.length <= max) {
			return str;
		} else {
			var pos;
			var $sentenceSymbol = new Array(".", "!", "?", " ");
			for (i = 0; i < max; i++) {
				if ($sentenceSymbol.indexOf(str[i]) != -1) {
					pos = i;
				}
			}
			var newStr = str.substring(0, pos + 1) + "...";
			return newStr;
		}
	}

	function chek() {
		console.log("10000");
	}

	window.Common = Common;
}(window));